/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.*;

/**
 * <p>Project: javaseapp - Map1
 * <p>Powered by webrx On 2021-08-10 08:46:28
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Map2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>(List.of("java", "c", "php", "mysql"));
        System.out.println(list);
        //list 是变的
        Collections.sort(list);
        System.out.println(list);

        Map<String, String> map = new HashMap<>();
        map.put("k5", "go");
        map.put("k6", "ruby");
        map.put("k7", "php");
        map.put("k1", "c");
        map.put("k2", "java");
        map.put("k3", "python");
        map.put("k4", "javascript");

        Collection<String> v = map.values();
        System.out.println(v);
        List<String> vs = new ArrayList<String>(v);
        //Collections.sort(vs); 升序
        //降序
        Collections.sort(vs, Comparator.reverseOrder());
        System.out.println(vs);

        //将map 的key集合 排序
        Set<String> keys = map.keySet();
        List<String> likey = new ArrayList<>(keys);
        Collections.sort(likey);//默认升序
        //降序
        Collections.sort(likey, Comparator.reverseOrder());
        System.out.println(likey);
        for (String k : likey) {
            System.out.println(map.get(k));
        }
    }
}
